Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

@smithy/middleware-retry

Package Overview
Dependencies
27
Maintainers
2
Versions
52
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @smithy/middleware-retry

[![NPM version](https://img.shields.io/npm/v/@smithy/middleware-retry/latest.svg)](https://www.npmjs.com/package/@smithy/middleware-retry) [![NPM downloads](https://img.shields.io/npm/dm/@smithy/middleware-retry.svg)](https://www.npmjs.com/package/@smithy


Version published
Weekly downloads
11M
decreased by-16.36%
Maintainers
2
Install size
1.33 MB
Created
Weekly downloads
 

Package description

What is @smithy/middleware-retry?

@smithy/middleware-retry is a middleware package for the AWS SDK for JavaScript (v3) that provides retry functionality. It allows you to automatically retry failed requests based on customizable retry strategies, which can help improve the reliability and resilience of your applications.

What are @smithy/middleware-retry's main functionalities?

Standard Retry Strategy

The StandardRetryStrategy provides a default retry strategy that retries failed requests with exponential backoff and jitter. This is useful for handling transient errors and improving the reliability of your application.

const { StandardRetryStrategy } = require('@smithy/middleware-retry');
const retryStrategy = new StandardRetryStrategy();

// Use the retry strategy in a client configuration
const client = new SomeAWSClient({
  region: 'us-west-2',
  retryStrategy
});

Custom Retry Strategy

You can create a custom retry strategy by extending the RetryStrategy class and implementing your own logic for determining when to retry and how many attempts to make. This allows you to tailor the retry behavior to your specific needs.

const { RetryStrategy } = require('@smithy/middleware-retry');

class CustomRetryStrategy extends RetryStrategy {
  shouldRetry(error) {
    // Custom logic to determine if the request should be retried
    return error.retryable;
  }

  getMaxAttempts() {
    // Custom logic to determine the maximum number of retry attempts
    return 5;
  }
}

const customRetryStrategy = new CustomRetryStrategy();

// Use the custom retry strategy in a client configuration
const client = new SomeAWSClient({
  region: 'us-west-2',
  retryStrategy: customRetryStrategy
});

Adaptive Retry Strategy

The AdaptiveRetryStrategy dynamically adjusts the retry behavior based on the observed success and failure rates of requests. This can help optimize the retry behavior for different network conditions and improve overall performance.

const { AdaptiveRetryStrategy } = require('@smithy/middleware-retry');
const adaptiveRetryStrategy = new AdaptiveRetryStrategy();

// Use the adaptive retry strategy in a client configuration
const client = new SomeAWSClient({
  region: 'us-west-2',
  retryStrategy: adaptiveRetryStrategy
});

Other packages similar to @smithy/middleware-retry

Readme

Source

@smithy/middleware-retry

NPM version NPM downloads

Usage

See @smithy/util-retry for retry behavior and configuration.

See also: AWS Documentation: Retry behavior.

FAQs

Last updated on 18 Jun 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc